<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      var str = prompt("请输入您的出生日期");
      var num = parseInt(str);
      var age = 2022 - num;
      //var age = 2022- str 隐式转换
      alert("您今年" + age + "岁了");
    </script>
  </head>
  <body></body>
</html>
